//
//  SpellSubviewController.h
//  This file is part of D&D Manager
//
//  Created by Matthew Hutton on 11/02/2007.
//
//
//D&D Manager, a D&D Character and battle management program.
//Copyright (C) 2007, Matthew Hutton
//
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License along with this program; if not, write to:
//The Free Software Foundation, Inc.,
//51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#import <Cocoa/Cocoa.h>
#import "MetaMagicFeatController.h"

@interface SpellSubviewController:NSObject{
	//spells per day screen.
	IBOutlet NSBox *spellsPerDayBox;
	IBOutlet NSTextField *domainSpells;
	IBOutlet NSTextField *noOfDomainSpells;
	IBOutlet NSTableView *spellsPerDayTable;
	IBOutlet NSTextField *spellAbilityO;
	IBOutlet NSTextField *spellAbilityBonus;
	IBOutlet NSTextField *spellTotal;
	IBOutlet NSTextField *spellTotal2;
	IBOutlet NSTextField *spellsLeft;
	IBOutlet NSTextField *spellsCast;
	IBOutlet NSTextField *spellsBase;
	IBOutlet NSTextField *spellsMiscBonus;
	IBOutlet NSTextField *totalAvailableSpells;
	IBOutlet NSView *totalSpellOptionsView;
	IBOutlet NSPopUpButton *domainMenu1;
	IBOutlet NSPopUpButton *domainMenu2;
	IBOutlet NSTextField *spellSaveModTF;
	IBOutlet NSTextField *spellPenetrationTF;
	//overall views/tabviews.
	IBOutlet NSView *spellsAvailableView;
	IBOutlet NSTabView *spellOptionsTabs;
	IBOutlet NSTabView *memorisedSpellsTabs;
	IBOutlet NSView *memorisedSpellsTotalView;
	IBOutlet NSTextField *memorisedSpellsClass;
	IBOutlet NSView *memorisedSpellView;
	IBOutlet NSTableView *memorisedSpellTable;
	BOOL memorisedWasSelected;
	IBOutlet NSTextField *domainSpellsBlurb;
	IBOutlet NSTextField *domainSpellsSpellbookBlurb;
	IBOutlet NSTableView *spellsOfLevelTable;
	IBOutlet NSButton *removeFromMemorisedSpellsButton;
	IBOutlet NSButton *addToMemorisedSpellsButton;
	IBOutlet NSView *noView;
	IBOutlet NSTextField *tooManySpellsTF;
	IBOutlet NSTextField *tooFewSpellsTF;
	//meta magic labels.
	IBOutlet NSButton *metaMagicFeats;
	MetaMagicFeatController *mmFeatController;
	//labels
	IBOutlet NSTextField *tooManySpells;
	IBOutlet NSTextField *tooFewSpells;
	//tables for spellbook
	IBOutlet NSTableView *availableSpellsTable;
	IBOutlet NSTableView *currentCharactersSpellsTable;
	IBOutlet NSButton *addToSpellbookButton;
	IBOutlet NSButton *removeFromSpellbookButton;
	//multiple class tab views
	//context/model.
	NSManagedObjectContext *mObjC;
	NSManagedObjectModel *model;
	//external functions.
	NSArrayController *charController;
	NSArrayController *spellController;
	NSTabView *characterTabView;
	//for storage of objects
	NSMutableArray *currentCharactersSpellClasses;
	NSMutableArray *availableSpells;
	NSMutableArray *memorisedSpells;
}
-(id)initWithCharController:(NSArrayController *)cCont
		withSpellController:(NSArrayController *)sCont
			withCharTabView:(NSTabView *)tabView;
-(NSManagedObjectContext *)managedObjectContext;
-(void)processAddToSpellbookButton;
-(void)processingCharacter:(NSManagedObject *)obj
		withCharacterClass:(NSManagedObject *)characterClass;
-(void)processSpellBasicsForCharacterClass:(NSManagedObject *)characterClass;
-(void)processSpellbookForCharacterClass:(NSManagedObject *)characterClass
							forCharacter:(NSManagedObject *)obj;
-(void)reloadSpellTables;
-(void)setupAddToMemorisedButton;
-(void)setupAvailableSpells;
-(void)setupCurrentCharactersSpells;
-(void)setupMemorisedSpells;
-(IBAction)setUpSpellsPerDay:(id)sender;
-(void)setUpSpellsPerDayData;
-(void)sortTooManyAndTooFewLabelsForSpellLevel:(NSManagedObject *)spellLevel
							 forCharacterClass:(NSManagedObject *)characterClass;
-(IBAction)spellToSpellbook:(id)sender;
-(IBAction)spellFromSpellbook:(id)sender;
-(IBAction)spellToMemorised:(id)sender;
-(void)spellToMemorisedPartTwoForTempSpellClass:(NSManagedObject *)tempSpellClass;
-(IBAction)spellFromMemorised:(id)sender;
-(void)metamagicSheetDidEnd:(NSWindow *)sheet
				 returnCode:(int)returnCode
				contextInfo:(NSManagedObject *)tempSpellClass;
-(void)setupDomainsList;
-(IBAction)domain1Setup:(id)sender;
-(IBAction)domain2Setup:(id)sender;
-(IBAction)spellSaveModSetup:(id)sender;
-(IBAction)spellPenetrationSetup:(id)sender;
//view setup functions.
-(BOOL)createSpellLevels:(NSManagedObject *)characterClass
				 forChar:(NSManagedObject *)obj;
-(void)processMagicView:(NSTabViewItem *)magicView
			   forClass:(NSManagedObject *)characterClass
				forChar:(NSManagedObject *)obj;
-(void)checkTotalSpellsCountForClass:(NSManagedObject *)characterClass
						forCharacter:(NSManagedObject *)obj;
-(void)setUpMemorised:(NSTabView *)tabViewItem
			  forChar:(NSManagedObject *)obj
			 forClass:(NSManagedObject *)characterClass;
-(void)tableViewSelectionDidChange:(NSNotification *)notification;
- (void)tabView:(NSTabView *)tabView
didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
-(BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex;
//table data view methods.
-(int)numberOfRowsInTableView:(NSTableView *)aTableView;
-(id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
		   row:(int)row;
@end
